package com.pro.xwt.rest.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pro.xwt.common.model.BEmployee;
import com.pro.xwt.common.vo.TreeNode;
import com.pro.xwt.rest.ResponseResult;
import com.pro.xwt.rest.service.TreeNodeService;

@Controller
@RequestMapping("/treeNode")
public class TreeNodeController {

	@Autowired
	TreeNodeService treeNodeService;

	@RequestMapping(value = "/deptEmp", method = { RequestMethod.GET })
	@ResponseBody
	public ResponseResult getDeptEmpTree(HttpServletRequest request) {
		BEmployee bEmployee = (BEmployee)request.getAttribute("user");
		List<TreeNode<Integer, String>> objectList = treeNodeService.selectDeptEmpTree(bEmployee);
		if (objectList.size() > 0) {
			return ResponseResult.success("获取树结构成功", objectList);
		} else {
			return ResponseResult.fail("获取树结构失败", objectList);
		}

	}

}
